/**
 * File  : Socket.cc
 * Time  : 2015-01-05 10:53
 * Author: KashingLee
 * Ref   : Null
 */
#include "Socket.h"


Socket::Socket() :sockfd_(-1), type_(0), family_(0) {}

Socket::Socket(int family, int type)\
    :sockfd_(-1), type_(type), family_(family) 
{
}

Socket::~Socket() {
  sockfd_ = -1; 
}

int Socket::Getfd() {
  if (-1 == sockfd_) {
    sockfd_ = socket(family_, type_, 0);
    if (-1 == sockfd_) {
      //TODO exceptions
      throw -1;
    }
  }
  return sockfd_;
}

int Socket::ShutDown(int how) {
  return shutdown(sockfd_, how);
}
int Socket::Close() {
  return close(sockfd_);
}
